package com.ssm.web;

import com.ssm.Service.addShopService;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;

@WebServlet(name = "addShopServlet",urlPatterns = "/addShop")
public class addShopServlet extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        request.setCharacterEncoding("utf-8");

        String name=request.getParameter("name");

        String picture=request.getParameter("picture");

        addShopService addShopService=new addShopService();

        boolean add = addShopService.add(name, picture);

        if(add){
            PrintWriter writer = response.getWriter();
            writer.print(add);
            writer.close();

            response.sendRedirect(request.getContextPath()+"/");
        }else{
            response.sendRedirect(request.getContextPath()+"jsp/404.jsp");
        }


    }

}
